#include <QApplication>
#include <QScreen>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationName("ScreenSplitAssist");
    a.setApplicationVersion("1.0.0");

    // 解析命令行参数
    QCommandLineParser parser;
    parser.setApplicationDescription("Screen Split Assistant");
    parser.addHelpOption();
    parser.addVersionOption();

    QCommandLineOption targetScreenOption("targetDisplayScreenName", "The name of the target display screen.", "screenName");
    parser.addOption(targetScreenOption);

    QCommandLineOption splitCountOption("screenSplitCount", "The number of screen splits (1/4/6/9).", "splitCount");
    parser.addOption(splitCountOption);
    
    QCommandLineOption defaultBKImageFilePathOption("defaultBKImageFilePath", "The path of screen default background image file's path.", "bkImagePath");
    parser.addOption(defaultBKImageFilePathOption);

    parser.process(a);

    QString targetScreenName = parser.value(targetScreenOption);
    QString splitCountStr = parser.value(splitCountOption);
    QString defaultBKImageFilePath = parser.value(defaultBKImageFilePathOption);
    int splitCount = 1;
    if (splitCountStr == "1" || splitCountStr == "4" || splitCountStr == "6" || splitCountStr == "9") {
        splitCount = splitCountStr.toInt();
    }

    MainWindow w(targetScreenName, splitCount, defaultBKImageFilePath);
    w.showFullScreen();

    return a.exec();
}
